﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ICSharpCode.Core;
using System.Windows.Input;
using Agnes.Core;

namespace Agnes.MyDocsLib
{
    /// <summary>
    /// 启动文档库之前执行的命令
    /// </summary>
    public class MyDocsLibCmd : AbstractCommand
    {
        /// <summary>
        /// Run
        /// </summary>
        public override void Run()
        {
            AgnesServiceManager.LogServ.Info("注册文档库的WPF命令！");
            //新建子目录命令
            AgnesCommandService.CommandBindings.Add(new CommandBinding(NewSubCatalogCmd.Requery,
                new ExecutedRoutedEventHandler(NewSubCatalogCmd.Instance.Excuted),
                new CanExecuteRoutedEventHandler(NewSubCatalogCmd.Instance.CanExcute)));

            //新建同级目录命令
            AgnesCommandService.CommandBindings.Add(new CommandBinding(NewSameLevelCatalogCmd.Requery,
                new ExecutedRoutedEventHandler(NewSameLevelCatalogCmd.Instance.Excuted),
                new CanExecuteRoutedEventHandler(NewSameLevelCatalogCmd.Instance.CanExcute)));

            //新建文章命令
            AgnesCommandService.CommandBindings.Add(new CommandBinding(NewArticleCmd.Requery,
                new ExecutedRoutedEventHandler(NewArticleCmd.Instance.Excuted),
                new CanExecuteRoutedEventHandler(NewArticleCmd.Instance.CanExcute)));

            //浏览文章命令
            AgnesCommandService.CommandBindings.Add(new CommandBinding(PreviewArticleCmd.Requery,
                new ExecutedRoutedEventHandler(PreviewArticleCmd.Instance.Excuted),
                new CanExecuteRoutedEventHandler(PreviewArticleCmd.Instance.CanExcute)));

            //编辑文章命令
            AgnesCommandService.CommandBindings.Add(new CommandBinding(EditArticleCmd.Requery,
                new ExecutedRoutedEventHandler(EditArticleCmd.Instance.Excuted),
                new CanExecuteRoutedEventHandler(EditArticleCmd.Instance.CanExcute)));

            //保存文章命令
            AgnesCommandService.CommandBindings.Add(new CommandBinding(SaveDocCmd.Requery,
                new ExecutedRoutedEventHandler(SaveDocCmd.Instance.Excuted),
                new CanExecuteRoutedEventHandler(SaveDocCmd.Instance.CanExcute)));

            //重命名命令
            AgnesCommandService.CommandBindings.Add(new CommandBinding(RenameCmd.Requery,
                new ExecutedRoutedEventHandler(RenameCmd.Instance.Excuted), 
                new CanExecuteRoutedEventHandler(RenameCmd.Instance.CanExcute)));

            //删除目录命令
            AgnesCommandService.CommandBindings.Add(new CommandBinding(DeleteCatalogCmd.Requery,
                new ExecutedRoutedEventHandler(DeleteCatalogCmd.Instance.Excuted),
                new CanExecuteRoutedEventHandler(DeleteCatalogCmd.Instance.CanExcute)));

            //删除文章命令
            AgnesCommandService.CommandBindings.Add(new CommandBinding(DeleteArticleCmd.Requery,
                new ExecutedRoutedEventHandler(DeleteArticleCmd.Instance.Excuted),
                new CanExecuteRoutedEventHandler(DeleteArticleCmd.Instance.CanExcute)));

            //导入命令
            AgnesCommandService.CommandBindings.Add(new CommandBinding(ImportCmd.Requery,
                new ExecutedRoutedEventHandler(ImportCmd.Instance.Excuted),
                new CanExecuteRoutedEventHandler(ImportCmd.Instance.CanExcute)));

            //导出命令
            AgnesCommandService.CommandBindings.Add(new CommandBinding(ExportCmd.Requery,
                new ExecutedRoutedEventHandler(ExportCmd.Instance.Excuted),
                new CanExecuteRoutedEventHandler(ExportCmd.Instance.CanExcute)));
        }
    }
}
